package automaton;

public class StateTransition {
	
	private State from;
	private State to;
	private char by;
	private char output;
	
	/* getter & setter */
	
	public State getFrom() {
		return from;
	}
	public void setFrom(State from) {
		this.from = from;
	}
	public State getTo() {
		return to;
	}
	public void setTo(State to) {
		this.to = to;
	}
	public char getBy() {
		return by;
	}
	public void setBy(char by) {
		this.by = by;
	}

	@Override
	public String toString() {
		return "(" + this.from + "--(" + this.by + ")->" + this.to + " >>>" + this.getOutput() + ")";
	}
	/* Konstruktor & create() */
	
	private StateTransition(State from, char by, State to, char output) {
		this.setFrom(from);
		this.setTo(to);
		this.setBy(by);	
		this.setOutput(output);
	}
	
	public static StateTransition create(State from, char by, State to, char output){
		return new StateTransition(from, by, to, output);
	}
	
	@Override
	public boolean equals(final Object argument) {

		if (argument instanceof StateTransition) {
			final StateTransition argumentAsStateTransition = (StateTransition) argument;
			return argumentAsStateTransition.getBy() == this.getBy()
					&& argumentAsStateTransition.getFrom().equals(this.getFrom())
					&& argumentAsStateTransition.getTo().equals(this.getTo())
					&& argumentAsStateTransition.getOutput() == this.getOutput();
		}
		return false;
	}
	public char getOutput() {
		return output;
	}
	public void setOutput(char output) {
		this.output = output;
	}


}
